package com.shu.logsearch.jsch.util;

import com.jcraft.jsch.SftpProgressMonitor;

/**
 * @author Tree Cai
 * @date 2019/7/3
 */
public class FtpProgressMonitor implements SftpProgressMonitor {
    /**
     * 文件总字节数
     */
    private long max;
    /**
     * 当前已接收的文件字节数
     */
    private long sumCount = 0;

    @Override
    public void init(int op, String src, String dest, long max) {
        System.out.println(String.format("-->开始传输文件 %s 到 %s", src, dest));
    }

    @Override
    public boolean count(long count) {
        for (int i = 0; i < ("已传输: " + sumCount + "bytes").length(); i++)
            System.out.print("\b");
        sumCount = sumCount + count;
        System.out.print("已传输: " + sumCount + "bytes");

        return true;
    }

    @Override
    public void end() {
        System.out.println("\n传输成功！");
    }
}
